package cn.linshu.security.jwt.service.impl;

import cn.linshu.security.jwt.entity.SysUser;
import cn.linshu.security.jwt.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

/**
 * -*- coding: utf-8 -*-
 *
 * @Author linnin
 * @Name springboot3-labs-master
 * @Time 2025/2/7 12:24
 * @Note
 * @For
 * @Out Copyright© 2025 linnin
 */

/* coding: utf-8 */
@Service("userDetailsService")
public class UserDetailsServiceImpl implements UserDetailsService {
    @Autowired
    private SysUserService sysUserService;
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        SysUser userByUsername = sysUserService.findUserByUsername(username);
        if (userByUsername == null) {
            return null;
        }
        return new SysUserDetails(userByUsername,new ArrayList<>());
    }
}
